package cn.gd.controller.systemAdministration.sysLog;

import cn.gd.pojo.SysLog;
import cn.gd.service.systemAdministration.sysLog.SysLogService;
import cn.gd.utils.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/sysLog")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    @PostMapping("/getSysLogList")
    public Result<Object> getSysLogList(
            @RequestParam Integer pageNum,
            @RequestParam Integer pageSize,
            @RequestParam(required = false) String userName,
            @RequestBody(required = false) String... dateRange
    ){
        System.out.println(dateRange);
        PageInfo<SysLog> sysLogList = sysLogService.querySysLogList(pageNum, pageSize, userName, dateRange);
        if (sysLogList != null) {
            return Result.ok(sysLogList);
        }
        return Result.error().message("无任何数据");
    }
}
